Phase 3 polish: journal validation, CRUD, time filters, agent robustness#3
Merged
Merged
Conversation
Follow-up to the merged Phase 3 (PR #2), hardening the trade journal and agent: - Input validation on POST/PATCH journal bodies (side long/short, positive size/price/timestamps, exited_at_ns >= entered_at_ns) -> 422 on bad input. - Full journal CRUD: GET/PATCH/DELETE /journal/{id} plus journal.get_entry/ update_entry/delete_entry. - Time-range filters (since_ns/until_ns) on GET /journal and /journal/analyze. - Agent robustness: coach.analyze raises AnalysisUnavailable when the model returns no structured output (refusal or empty parse); the endpoint maps it to 502 instead of a 500 on a null body. - scripts/verify_pipeline.sh: keyless end-to-end smoke (tape -> engine -> metrics.db -> journal -> regime join). Hermetic test_integration.py covers the HTTP flow in CI. - Document the nanosecond/JSON safe-integer caveat as a Phase 4 dashboard concern. - Tests for all of the above; README updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DcbYTwtqmAgEkcTtJtsztt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the merged Phase 3 (#2), hardening the trade journal + behavioral agent so Phases 1–3 are solid before the Phase 4 dashboard. No Rust changes.
What changed
JournalEntryIn/ newJournalEntryPatch):side ∈ {long, short}, positivesize/entry_price/entered_at_ns, andexited_at_ns ≥ entered_at_ns— invalid bodies now return 422 instead of being silently stored.GET/PATCH/DELETE /journal/{id}plusjournal.get_entry/update_entry/delete_entry(partial updates never touchid/created_at_ns). Rounds the journal out as a real resource for the Phase 4 dashboard.since_ns(inclusive) /until_ns(exclusive) onGET /journalandPOST /journal/analyze, to scope analysis to a session/day.messages.parse().parsed_outputisOptional(it'sNoneon a safety refusal or an empty structured parse).coach.analyzenow raisesAnalysisUnavailable, and/journal/analyzemaps it to a 502 instead of a 500 on anullbody.scripts/verify_pipeline.shruns the real pipeline keyless (tape → Rust engine →metrics.db→ journal seed → regime join). A hermetictest_integration.pyexercises the HTTP flow in CI.*_nsas string/BigInt) rather than changing the Phase 1–2 contract now.Verification
cd backtest && ruff check . && ruff format --check . && pytest→ 65 passed, lint clean.cd engine && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test→ 10 passed, clean (confirms Phase 1–2 still green).bash scripts/verify_pipeline.sh→ 5000 ticks → 501 buckets → 12/12 journal entries joined to a regime.🤖 Generated with Claude Code